Introduction

The Rail package allows you to include syntax diagrams (also known as railroad diagrams) in a LATEX document. Such a diagram looks like this:
\begin{rail}
\par
decl : 'def' identifier '=' ( expression + ';' )
\vert 'type' identifier '=' type
;
\par
\end{rail}
The idea is that any sequence of terminals and nonterminals that can be produced by starting at the left and following the lines is a valid sentence of some language. As such, these diagrams are analogous to BNF with embedded regular expressions for each right-hand side. Actually, the input language looks like that, except that production rules need not be named and there is some extra annotation. This document describes version 1.0 #1 of the Rail package.